(function($) {
        
    $.fn.quickPager = function(options) {
    
        var defaults = {
            pageSize: 10,
            active: 1,
            holder: ""
    	};
    	var options = $.extend(defaults, options);
      	
        //leave this
        var selector = $(this);
        var totalRecords = $(this).children().length;
        var pageCounter = 1;

        selector.children().each(function(i){
            if(i < pageCounter*options.pageSize && i >= (pageCounter-1)*options.pageSize) {
                $(this).addClass("page"+pageCounter);
            }
            else {
                $(this).addClass("page"+(pageCounter+1));
                pageCounter ++;
            }	
        });
         
        //show/hide the appropriate regions 
        selector.children().hide();
        $(".page"+options.active).show();
        
        //first check if there is more than one page. If so, build nav
        if(pageCounter > 1) {
            
            //Build pager navigation
            var pagination = "<div class='pagination floatright'>";	
            for (i=1;i<=pageCounter;i++){
                
                                
                if (i==options.active) {
                    pagination += "<a class=active rel='"+i+"'><span>"+i+"</span></a><lable> </lable>";	
                }
                else {
                    pagination += "<a  rel='"+i+"'><span>"+i+"</span></a>";
                }
                
            }

            pagination += "</div>";
            
            if(options.holder == "") {
                selector.after(pagination);
            }
            else {
                $(options.holder).append(pagination);
            }
                        
            //pager navigation behaviour
            $(".pagination a").live("click", function() {			
                //grab the REL attribute 
                var clickedLink = $(this).attr("rel");
                options.active = clickedLink;
                //remove current current (!) page
                $("a.active").removeClass("active");
                //Add current page highlighting
                $("div.pagination").find("a[rel='"+clickedLink+"']").parent("a").addClass("active");
                //$(this).parent("li").addClass("currentPage");
                //hide and show relevant links				
                selector.children().hide();			
                selector.find(".page"+clickedLink).show();
                return false;
            });
            
        }
              
    }
    

})(jQuery);